#!/usr/bin/env python3
"""
AI Agent 快速演示脚本
"""

import asyncio
import sys
from pathlib import Path

# 添加项目根目录到路径
sys.path.insert(0, str(Path(__file__).parent))

from agent.core import Agent, AgentConfig

async def quick_demo():
    """快速演示 AI Agent 功能"""
    print("🤖 AI Agent 快速演示\n")
    
    # 创建 Agent 配置
    config = AgentConfig(
        name="DemoAgent",
        provider="ollama",
        model="qwen3:8b",
        temperature=0.7,
        verbose=False,  # 关闭详细输出以便于测试
        ollama_base_url="http://localhost:11434"
    )
    
    # 创建 Agent
    agent = Agent(config)
    
    print(f"✅ Agent 创建成功！使用模型: {config.model}")
    print(f"📦 可用工具: {len(agent.tool_registry.list_tools())} 个")
    
    # 测试用例
    test_cases = [
        "你好，请介绍一下你自己",
        "计算 15 * 24 + 37",
        "搜索 Python 编程教程",
        "帮我分析一下 AI Agent 的核心组件"
    ]
    
    for i, test_case in enumerate(test_cases, 1):
        print(f"\n{'-'*50}")
        print(f"测试 {i}: {test_case}")
        print(f"{'-'*50}")
        
        try:
            response = await agent.process_input(test_case)
            print(f"Agent 回复: {response}")
        except Exception as e:
            print(f"❌ 错误: {e}")
        
        # 等待一下避免请求过快
        await asyncio.sleep(1)
    
    print(f"\n{'='*50}")
    print("🎉 演示完成！")
    
    # 显示 Agent 状态
    status = agent.get_status()
    print(f"\n📊 Agent 状态:")
    print(f"  - 对话轮数: {status['conversation_length']}")
    print(f"  - 当前状态: {status['state']}")
    print(f"  - 可用工具: {', '.join(status['available_tools'])}")

if __name__ == "__main__":
    asyncio.run(quick_demo())